//
//  MBDUserReportCell.swift
//  Pods
//
//  Created by kyson on 2023/10/26.
//

import Foundation

import YYText
import SnapKit


class MBDUserReportCell : MBDCommonCell {
    
    var titleLabel:YYLabel!
    private var selectedIconImageView : UIImageView!
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.initialize()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        
        self.initialize()
    }
    
    func initialize() {
        titleLabel = YYLabel()
        self.commonBackgroundView.addSubview(titleLabel)
        
        selectedIconImageView = UIImageView()
        selectedIconImageView.image = UIImage(named: "ico_right")
        self.commonBackgroundView.addSubview(selectedIconImageView)

        titleLabel.snp.makeConstraints { make in
            make.centerY.equalTo(commonBackgroundView)
            make.top.equalTo(14)
            make.left.equalTo(20)
        }
        
        selectedIconImageView.snp.makeConstraints { make in
            make.centerY.equalTo(titleLabel)
            make.left.equalTo(titleLabel.snp.right).offset(15)
        }
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        self.selectedIconImageView.isHidden = !selected
    }

    
    override var cellModel: Any! {
        didSet {
            let cellModel = self.cellModel as! MBDUserReportCellModel
            self.titleLabel.textLayout = cellModel.titleLayout
            
            self.selectedIconImageView.isHidden = true
            
            self.location = cellModel.location
            
        }
    }
    
    
}
